package com.ruoyi.housing.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ruoyi.housing.mapper.HousingDao;
import com.ruoyi.housing.service.HousingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 小智
 * @PachageName:com.ruoyi.housing.service.impl
 * @ClassName :HousingServiceImpl
 * @Description:
 * @date 2021/07/22 9:40
 */
@Service
public class HousingServiceImpl implements HousingService {

    @Autowired
    HousingDao housingDao;


    @Override
    public Object list(Map<String, Object> map) {
        Integer pageNum = Integer.valueOf(map.get("pageNum").toString());
        Integer pageSize = Integer.valueOf(map.get("pageSize").toString());

        PageHelper.startPage(pageNum,pageSize);

        List<Map<String,Object>> maps = housingDao.list(map);

        return new PageInfo<Map<String,Object>>(maps);
    }

    @Override
    public boolean updateById(String recommended) {
        String[] split = recommended.split(",");
        int i=0;
        for (String sor : split) {
           i+= housingDao.updateId(sor);
        }
        return i>0;
    }

    @Override
    public boolean updateById0(String id) {
        String[] split = id.split(",");
        int i=0;
        for (String sor : split) {
            i+= housingDao.updateById0(sor);
        }
        return i>0;
    }

}
